//
//  HFTableViewCell.m
//  LetsParty
//
//  Created by rimi on 15/9/9.
//  Copyright (c) 2015年 MLin. All rights reserved.
//

#import "HFTableViewCell.h"
@interface HFTableViewCell ()
- (void)initAppearance;
@end

@implementation HFTableViewCell

-(void)setFrame:(CGRect)frame{
    
    [super setFrame:frame];
    frame.origin.x = 10 * DHFlexibleHorizontalMutiplier();
    frame.size.width = 300 * DHFlexibleHorizontalMutiplier();
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initAppearance];
    }
    return self;
}
- (void)awakeFromNib{
    
}

- (void)initAppearance
{
    
    [self.contentView addSubview:self.titleLabel];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 30, 300, 0.5) adjustWidth:NO];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:lineView];
    
    _time = [[UILabel alloc] initWithFrame:CGRectMake(10, 38, 40, 20) adjustWidth:NO];
    _time.text = @"时间:";
    _time.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
    [self.contentView addSubview:_time];
    
    _address = [[UILabel alloc] initWithFrame:CGRectMake(10, 63, 40, 20) adjustWidth:NO];
    _address.text = @"地址:";
    _address.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
    [self.contentView addSubview:_address];
    
    _originator = [[UILabel alloc] initWithFrame:CGRectMake(10, 88, 55, 20) adjustWidth:NO];
    _originator.text = @"发起人:";
    _originator.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
    [self.contentView addSubview:_originator];
    
    _admin = [[UILabel alloc] initWithFrame:CGRectMake(10, 113, 68, 20) adjustWidth:NO];
    _admin.text = @"参加人数:";
    _admin.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
    [self.contentView addSubview:_admin];


    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.addressLabel];
    [self.contentView addSubview:self.originatorLabel];
    [self.contentView addSubview:self.intervenorLabel];
    [self.contentView addSubview:self.stateLabel];
    [self.contentView addSubview:self.detialButton];
    [self.contentView addSubview:self.adminButton];
    
    self.contentView.layer.cornerRadius = 20;
}
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 280, 30) adjustWidth:NO];
            label.font = [UIFont boldSystemFontOfSize:18 * DHFlexibleVerticalMutiplier()];
            label;
        });
    }
    return _titleLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_time.frame), CGRectGetMinY(_time.frame), 220 * DHFlexibleHorizontalMutiplier(), 20 * DHFlexibleVerticalMutiplier())];
            label.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
            label;
        });
    }
    return _timeLabel;

}
- (UILabel *)addressLabel
{
    if (!_addressLabel) {
        _addressLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_address.frame), CGRectGetMinY(_address.frame), 200 * DHFlexibleHorizontalMutiplier(), 20* DHFlexibleVerticalMutiplier())];
            label.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
            label;
        });
        
    }
    return _addressLabel;

}
- (UILabel *)originatorLabel
{
    if (!_originatorLabel) {
        _originatorLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_originator.frame), CGRectGetMinY(_originator.frame), 100*DHFlexibleHorizontalMutiplier(), 20* DHFlexibleVerticalMutiplier())];
            label.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
            label;
        });
    }
    return _originatorLabel;


}
- (UILabel *)intervenorLabel
{
    if (!_intervenorLabel) {
        _intervenorLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_admin.frame) - 2 , CGRectGetMinY(_admin.frame), 20* DHFlexibleHorizontalMutiplier(), 20* DHFlexibleVerticalMutiplier())];
            label.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
            label;
        });
    }
    return _intervenorLabel;

}
- (UILabel *)stateLabel
{
    if (!_stateLabel) {
        _stateLabel = ({
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(250, 115, 45, 18) adjustWidth:NO];
            label.textAlignment = NSTextAlignmentCenter;
            label.font = STATUS_FONT;
            label;
        });
        
    }
    return _stateLabel;

}
- (UIButton *)detialButton
{
    if (!_detialButton) {
        _detialButton = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = DHFlexibleFrame(CGRectMake(280, 5, 20, 20), NO);
            [button setImage:[UIImage imageNamed:@"iconfont-jiantouyou"] forState:UIControlStateNormal];
            button;
        });
        
    }
    return _detialButton;

}
- (UIButton *)adminButton
{
    if (!_adminButton) {
        _adminButton = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(CGRectGetMaxX(_intervenorLabel.frame) - 3, CGRectGetMinY(_intervenorLabel.frame), 40 * DHFlexibleHorizontalMutiplier(), 20 * DHFlexibleVerticalMutiplier());
            [button setTitle:@"(查看)" forState:UIControlStateNormal];
            button.titleLabel.font = [UIFont systemFontOfSize:15 * DHFlexibleVerticalMutiplier()];
            button.titleLabel.textAlignment = NSTextAlignmentLeft;
            [button setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
            button;

        });
    }
    return _adminButton;

}


@end
